﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WinFormUIXMLParser
{
    public class XmlLabelObject : XmlControlBase
    {
        public string TextAlign { get; set; }

        public bool AutoSize { get; set; }

        public XmlLabelObject()
            : base()
        {

        }
 
        public override string ToXMLString()
        {
            throw new NotImplementedException();
        }

        public void SetTextAlign(Label tb)
        {
            if (string.IsNullOrEmpty(TextAlign))
            {
                return;
            }
            ContentAlignment align = ContentAlignment.MiddleCenter;
            if (Enum.TryParse<ContentAlignment>(TextAlign, out align))
            {
                tb.TextAlign = align;
            }
        }

        public void SetAutoSize(Label label)
        {
            label.AutoSize = AutoSize;
        }

        public override void SetValues(Control ctl)
        {
            base.SetValues(ctl);
            SetTextAlign(ctl as Label);
            SetAutoSize(ctl as Label);
        }

        public override Control ToControl<T>(T parent)
        {
            Label label = new Label();
            SetValues(label);
            return label;
        }
    }
}
